In this post, I will analyze meteor landings throughout the world and take my first steps towards my goal of using astronomy and computer science to explore the mysteries of the universe!
The data for this project comes from NASA's open data portal - Nasa Meteorite Landings. This is an amazing treasure trove of information for space buffs directly from NASA.
In order to map these sites of meteor landings in Python, I will use the Folium module. Folium is a popular python library used to visualize geospatial data and create interactive maps.
First, lets load the Python modules that will be needed for this project. These include Pandas, Folium, Matplotlib, Math and Geopandas.
from folium.plugins import MarkerCluster
import pandas as pd
import folium
import matplotlib.pyplot as plt
import math
import geopandas
Download the Meteorite Landings csv file from this link -> Nasa Meteorite Landings
The next step is to read the csv file and see its structure. (Adjust the path name according to where you have downloaded the csv)
meteors_raw_data = pd.read_csv("./data/Meteorite_Landings.csv")
meteors_raw_data.head()
This dataset contains the meteor name, mass, year and geographic coordinates. Let's clean up the data and plot it on a map using their latitudes and longitudes.
The rows containg null or missing values for latitude and longitude are dropped and the result is plotted on a map.
As there are over 47,000 meteor landing points, plotting them together wil cause clutter on the map. So, I use a feature of Folium to cluster the points based on geography.
Upon clicking the cluster, we can zoom in and view the meteor details individually!
meteors = meteors_raw_data.dropna(subset=["reclong", "reclat"]).drop_duplicates(subset=["reclong", "reclat"])
map = folium.Map(tiles='cartodbpositron', zoom_start=2, location=[50.007146, -20.854878])
marker_cluster = MarkerCluster().add_to(map)
for index, row in meteors.iterrows():
name = row["name"]
year = str(row["year"])
latitude = row['reclat']
longitude = row['reclong']
popup_text = '<h3 style="color:green;">' + name + '</h3>'
if year.lower() != "nan":
popup_text = popup_text + year
folium.Marker(location = [latitude, longitude], tooltip = popup_text).add_to(marker_cluster)
map